<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/jsp/commons/taglibs.jsp" %>
<!DOCTYPE HTML>
<html ng-app>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <META HTTP-EQUIV="pragma" CONTENT="no-cache">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
    <title>${title}</title>
    <%@ include file="/WEB-INF/jsp/commons/meta.jsp" %>
    <link href="${ctx}/resources/new/style.css" type="text/css" rel="stylesheet"/>

</head>
<body>
<script>
    $(document).ready(function () {
        //聚焦第一个输入框
        //为inputForm注册validate函数
        $("#inputForm").validate({
            rules: {
                code: "required",
                createScale: "required",
                memo: "required",
                status: "required",
                boxNum: {
                    required: true,
                    number: true
                },
                goodsNum: {
                    required: true,
                    number: true
                },
                createScale: {
                    required: true,
                    number: true
                }
            }
        });
        if ($.trim($("#code").val()) == "") {
            $("#code").val(new Date().getTime());
        }
        $("#boxNum,#createScale").keyup(function () {
            countNum();
        }).blur(function () {
            countNum();
        });
        function countNum() {
            var scale = parseInt($("#createScale").val());
            var boxNum = parseInt($("#boxNum").val());
            $("#goodsNum").val(scale * boxNum);
            $("#goodsJNum").val(scale * boxNum);
            $("#goodsNum").change();
        }

        $("#goodsNum").change(function () {
            if (parseInt($(this).val()) > 0) {
                $("#createQr").removeAttr("disabled");
            } else {
                $("#createQr").attr("disabled", "disabled");
            }
        }).change();
        $("#createQr").click(function () {
            msgAlert.show("数据后台生成中，请稍后刷新数据列表查看状态！");
            $("#inputForm").attr("action", "${ctx}/adoms/qrBatch/create");
            ("#inputForm").submit();
        });
    });
</script>
<form id="inputForm" class="well form-inline" action="${ctx}/adoms/qrBatch/save" method="post">
    <input type="hidden" name="id" value="${qrBatch.id}"/>
    <table class="table table-striped table-bordered table-condensed">
        <thead>
        <i class="icon-flag"></i>
        <strong>二维码批量生成表单</strong>
        </thead>
        <tr>
            <td class="span2">系统编码:</td>
            <td>
                <input id="code" name="code" readonly="readonly" type="text" value="${qrBatch.code}" size="30"
                       maxlength="80"/>
            </td>
        </tr>
        <tr>
            <td>箱码数量:</td>
            <td>
                <input id="boxNum" name="boxNum" type="text" value="${qrBatch.boxNum}" size="30" maxlength="80"/>
            </td>
        </tr>
        <tr>
            <td>生成比例:</td>
            <td>
                箱码:商品二维码 = 1:
                <input class="span1" id="createScale" name="createScale" type="text" value="${qrBatch.createScale}"
                       size="10" maxlength="2"/>
                <span class="tBlue">1~99</span>
            </td>
        </tr>
        <tr>
            <td>二维码数量:</td>
            <td>
                <input readonly="readonly" id="goodsNum" name="goodsNum" type="text" value="${qrBatch.goodsNum}"
                       size="30" maxlength="80"/>
            </td>
        </tr>
        <tr>
            <td>积分码数量:</td>
            <td>
                <input readonly="readonly" id="goodsJNum" type="text" value="${qrBatch.goodsNum}" size="30"
                       maxlength="80"/>
            </td>
        </tr>
        <tr>
            <td>状态:</td>
            <td>
                <select id="status" name="status">
                    <c:if test="${not empty(qrBatch.status) }">
                        <option>${qrBatch.status }</option>
                    </c:if>
                    <option>未生成</option>
                    <option>已生成</option>
                    <option>已导出</option>
                </select>
            </td>
        </tr>
        <tr>
            <td>备注:</td>
            <td>
                <textarea id="memo" name="memo" rows="4" class="span6">${qrBatch.memo}</textarea>
            </td>
        </tr>
        <tr>
            <td align="center" colspan="2">
                <input class="btn btn-primary" type="submit" value="保存记录"/>
                &nbsp;
                <input disabled="disabled" id="createQr" class="btn btn-warning" type="submit" value="生成二维码"/>
                &nbsp;
                <input class="btn btn-primary" type="button" value="返 回" back="back" onclick="history.go(-1)"/>
            </td>
        </tr>
    </table>
</form>
</body>
</html>